
import React,{Component} from 'react'
import {Link} from 'react-router'
import 'assets/css/global.css'
import 'assets/css/Charts.css'
import market from    './sell/market'
import facility from  './facility/facility'
import Banner from    'assets/images/seting.png';
import copy from      'assets/images/copy.png';
import close from     'assets/images/close.png';
import logo from      'assets/images/user.png'
import chartsIco from 'assets/images/charts.png'
import {dialog} from 'action/deal'
import {userIfo} from 'action/operation'

export default class Show extends Component{
	
	constructor(props){
		super(props)
		this.state={
			Index:1,
			userName:'',
		}
	}
  
  componentWillMount(){
		//检查登录权限
		userIfo(sessionStorage.admin_token).then((response)=>{
			this.setState({
				userName:response
			})
		});
		
  }
  
  Active(e){
  	this.setState({Index: e.target.getAttribute('data-index')});
  }
  
  Exit(){
 		dialog('Exit')
  }
  
  render () {
    return (
      <div className="main">
        <header>
          <div className="top-left ad-fl">
            <h3>
          		<span>智</span>
          		<span>能</span>
          		<span>管</span>
          		<span>控</span>
          		<span>系</span>
          		<span>统</span>
            </h3>
            <div className="topDiv">
            	<span className="topSpan">Self energy management</span>
            </div>
          </div>
          <div className="top-right">
            <div className="topSpan ad-fl">
           	  <img className="top-right-user" src={logo} />
            	<span>{this.state.userName}</span></div>
            <nav>
							<ul>
								<li>
									<img className="handle-ico" src={Banner} />
								</li>
								<li>
								  <img className="handle-ico " src={copy} />
								  </li>
								<li onClick={this.Exit.bind(this)}>
									<img className="handle-ico" src={close} />
								</li>
							</ul>
						</nav>
          </div>
        </header>
        <article className="article1">
          <nav className="Left-Menu ad-fl">
            <Link to="/show-data"   
            	data-index="1" className={this.state.Index == 1? 'menuActive':''}
            	onClick={this.Active.bind(this)}>
            		<img src={chartsIco} className="chartsIco" />
            		销售大盘</Link>
            <Link to="/show-data/facility" 
            	className={this.state.Index == 2? 'menuActive':''} data-index="2"
            	onClick={this.Active.bind(this)}>
            		<img src={chartsIco}  className="chartsIco" />
            		设备大盘</Link>
	         	</nav>
            <section className="main-content">
                {this.props.children}
            </section>
        </article>
      </div>
    )
  }
}
